package com.gemme.gemme.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.gemme.gemme.R;
import com.gemme.gemme.shequ.CommunityBean;

public class GuanzhuSingleItemView extends RelativeLayout {
    private Context context;
    public GuanzhuSingleItemView(Context context) {
        this(context,null);
    }

    public GuanzhuSingleItemView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public GuanzhuSingleItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }

    ImageView iv_picture;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.guanzhu_single_item,this);
        iv_picture = findViewById(R.id.iv_picture);
    }


    public ImageView getIv_picture() {
        return iv_picture;
    }

    public void setData(CommunityBean.DataBean dataBean) {
        try {
            String videoPath = dataBean.getVideoPath();
            if(TextUtils.isEmpty(videoPath))
                return;
            Glide.with(context)
                    .setDefaultRequestOptions(
                            new RequestOptions()
                                    .frame(1000000)
                                    .centerCrop()
                    )
                    .load(videoPath)
                    .into(iv_picture);

        }catch (Exception e){

        }
    }
}
